from http.server import BaseHTTPRequestHandler, HTTPServer
import json

class MyHTTP(BaseHTTPRequestHandler):

    def do_POST(self):
        (addr, port) = self.client_address
        print(f'client->{addr}:{port}')
        print(self.headers)
        cont_len = int(self.headers.get("Content-Length"))
        data = self.rfile.read(int(self.headers.get("Content-Length")))
        data = json.loads(data)
        print(f'md_count: {data[1]["value"]}, dl_count: {data[0]["value"]}, type_count: {data[2]["value"]}')
        
        self.send_response(200)
        self.send_header("Content-type", "text/html")
        self.end_headers()

        response = "Json request successfully"
        self.wfile.write(response.encode())
        print('**********')



myhttp = HTTPServer(('127.0.0.1',13131), MyHTTP)

myhttp.serve_forever()